1. Field of the Invention
The present invention relates to an image processing apparatus, an image processing method, and a computer program product.
2. Description of the Related Art
When an image is captured by a digital camera, it becomes needed that lightness (brightness) of the image needs to be corrected. More specifically, in some cases, a subject of the image is dark because of underexposure in shooting in a backlight condition or during nighttime, or a part of the image is dark because the image contains a portion that shows shadow. Regarding such an image, for example, brightness of the image has been corrected by allowing a user to specify a correction level or a gamma shape, or automatically created of a gamma table based on features of the image and then gamma transformation is performed. Technologies for correcting an image have been proposed as disclosed in, for example, Japanese Patent No. 2748678, Japanese Patent No. 3134660, and Japanese Patent Application Laid-open No. H9-200531.
More specifically, Japanese Patent No. 2748678 discloses a tone correction method etc. for obtaining R, G, and B tone-corrected output signals such that a luminance signal is created based on R, G, and B signals, gamma transformation is performed on the luminance signal to obtain a desired tone characteristic with an arbitrary shape, and each of the R, G, and B signals is multiplied by a ratio of the gamma-transformed signal to the luminance signal.
Japanese Patent No. 3134660 discloses a color transforming apparatus etc. that includes a primary-color transforming unit that transforms a video signal formed of an input luminance signal and two input color-difference signals into three-primary-color signals; a maximum-value detecting unit that selectively allows a maximum-level output among outputs from the primary-color transforming unit to pass; a reference-value setting unit that sets an acceptable maximum level of the three-primary-color signals; a coefficient determining unit that determines a correction coefficient for limiting a value of the output from the maximum-value detecting unit to be equal to or smaller than a value of the output from the reference-value setting unit, depending on the luminance signal; and a multiplying unit that multiplies each of the two color-difference signals by the correction coefficient. The color transforming apparatus has a feature that an output from the multiplying unit is output as a new color-difference signal.
Japanese Patent Application Laid-open No. H9-200531 discloses an image-brightness transforming apparatus etc. that separates attribute values of brightness and color of an image from an RGB signal of each pixel, and transforms a brightness distribution of a brightness signal. More specifically, the image-brightness transforming apparatus includes a transformation table for brightness transformation, which is calculated from a histogram that represents color-image brightness that is measured through pre-scanning; and a transforming unit that performs the brightness transformation based on the histogram of the brightness signal that has been separated from the RGB signal. The image-brightness transforming apparatus has a feature that the brightness is re-transformed based on characteristics of the histogram.
When the gamma transformation is performed on each of RGB signals to make an image be brighter, as disclosed in Japanese Patent No. 2748678, hue and saturation of the image may be changed. More specifically, in a region on the highlight side (on the maximum brightness side) in which a slope of the gamma shape (gamma characteristics) is smaller than 1, saturation degradation in which an RGB ratio comes close to 1:1:1 may occur.
When the luminance signal and the two color-difference signals are obtained by performing linear transformation on the RGB signal and the gamma transformation is performed on the luminance signal to make an image be brighter, only a luminance is increased and a color difference is maintained. Therefore, in a region on the shadow side (on the minimum brightness side) in which the slope of the gamma shape (gamma characteristics) is larger than 1, the degree of correction increases, so that the saturation degradation in which the RGB ratio comes close to 1:1:1 remarkably occurs.
Regarding the above-mentioned points, according to the technology disclosed in Japanese Patent No. 2748678, the brightness can be adjusted without changing the hue and the saturation. However, in the technology disclosed in Japanese Patent No. 2748678, as mentioned in Japanese Patent No. 3134660, color obtained after the tone correction may be saturated depending on color present before the tone correction. If such a situation occurs, a luminance level obtained after the tone correction remains smaller than a desired luminance level, and the hue and the saturation are also changed.
On the other hand, according to the technology disclosed in Japanese Patent No. 3134660, the correction coefficient for the color-difference signals is limited to prevent occurrence of saturation in color reproduction, so that a luminance correction can be performed to conform to a desired gamma characteristics.
In the sRGB color space that is a color space used in a typical monitor, each of RGB signals is limited (normalized) to a range from 0 to 1. In the sYCC color space that is used in images captured by a typical digital camera, color is represented by a luminance signal Y and color-difference signals Cb and Cr. While the sYCC color space and the sRGB color space can be linearly transformed from one to the other, the sYCC color space can express a wider range of colors than the sRGB color space. However, because the monitor employs the sRGB color space, when an image captured by the digital camera is displayed on the monitor, only colors in a range that can be expressed in the sRGB color space are displayable, so that each of the RGB signals is to be limited to the range from 0 to 1.
The following Equations (1) to (3) are used as Equations for calculating YCbCr signals from RGB signals.Y=0.2990×R+0.5870×G+0.1140×B  (1)Cb=−0.1687×R−0.3312×G+0.5000×B  (2)Cr=0.5000×R−0.4187×G−0.0813×B  (3)
Further, the following Equations (4) to (6) are used as Equations for calculating RGB signals from YCbCr signals.R=Y+1.4020×Cr  (4)G=Y−0.3441×Cb−0.7141×Cr  (5)B=Y+1.7720×Cr  (6)
Meanwhile, when the brightness is corrected by applying a single gamma table to the entire portion of a single image, there is a case that correction may not be performed as desired by a user. For example, when an image shows a night scene containing a red light sign board, there may be a case that a user wants to perform correction to make only a dark portion having low visibility be brighter and does not want to perform correction on a red light sign board portion having good visibility. In such a situation, if the single gamma table is uniformly applied to the entire portion of the single image, the red light sign board portion is corrected to be brighter while the portion having the low visibility is corrected to be brighter. Accordingly, red in the light sign board portion becomes a whitish faded color, resulting in decreased quality of the image. To perform correction on such an image as desired by a user, one possible measure is to locally change a gamma table in a single image by identifying color or peripheral information (scene etc.). However, in this measure, the following concerns may easily be raised: discontinuous tone may appear because of the change of the gamma table; and an amount of information processing may increase because of reference to the peripheral information.